{% extends "base/document.html" %}
{% load crispy_forms_tags %}
{% block title %}
  {% trans "Meal Type List" %}
{% endblock %}
{% block content %}
  <h1>{% trans "Meal type list" %}</h1>
  <hr />
  <div class="d-flex justify-content-end pt-2">
    <a class="btn btn-primary"
       onclick="open_small_window('{% url 'canteen:create_meal_type' %}'); return false;">{% trans "Add" %}</a>
  </div>
  <table class="table table-bordered table-striped table-hover table-condensed">
    <thead>
      <tr>
        <th>#</th>
        <th>{% trans "Meal Type Name" %}</th>
        <th>{% trans "Abbreviation" %}</th>
        <th>{% trans "Created at" %}</th>
        <th>{% trans "Is Disabled" %}</th>
        <th>#</th>
      </tr>
    </thead>
    <tbody>
      {% for meal_type in meal_types %}
        <tr>
          <td>{{ forloop.counter }}</td>
          <td>{{ meal_type.name }}</td>
          <td>{{ meal_type.abbreviation }}</td>
          <td>{{ meal_type.created_at|date:"Y-m-d" }}</td>
          <td>
            {% if meal_type.is_disabled %}
              {% trans "Yes" %}
            {% endif %}
          </td>
          <td>
            <a class="text-primary"
               target="_blank"
               onclick="open_small_window('{% url 'canteen:update_meal_type' meal_type.id %}'); return false; ">{% trans "Edit" %}</a>
            |
            <a class="text-danger"
               onclick="open_small_window('{% url 'canteen:delete_meal_type' meal_type.id %}'); return false; "
               target="_blank">{% trans "Delete" %}</a>
          </td>
        </tr>
      {% empty %}
        <tr>
          <td colspan="2">{% trans "No meal types yet." %}</td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
  {% include "includes/_paginator.html" %}
  <script>
    $(document).ready(function() {
      localize_content($("td"))
    });
  </script>
{% endblock %}
